Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pure-rand

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-rand

Pure random number generator written in TypeScript

  • 6.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.9M
decreased by-55.13%
Maintainers
1
Weekly downloads
 
Created

What is pure-rand?

The pure-rand npm package is a library designed for generating random numbers in a pure and functional way. It supports various types of random number generation methods and can be used in scenarios where deterministic results are needed from random inputs by providing seed-based generation.

What are pure-rand's main functionalities?

Generating random integers

This feature allows the generation of random integers within a specified range. The example shows how to generate a random integer between 1 and 100 using a seeded Mersenne Twister algorithm.

import { Random, MersenneTwister19937 } from 'pure-rand';
const randomGenerator = MersenneTwister19937.seed(1234);
const randomInt = Random.integer(1, 100)(randomGenerator);
console.log(randomInt);

Generating random arrays

This feature enables the creation of arrays filled with random integers. The code sample demonstrates generating an array of 10 random integers, each between 1 and 100.

import { Random, MersenneTwister19937 } from 'pure-rand';
const randomGenerator = MersenneTwister19937.seed(5678);
const randomArray = Random.array(Random.integer(1, 100), 10)(randomGenerator);
console.log(randomArray);

Other packages similar to pure-rand

Keywords

FAQs

Package last updated on 20 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc